const { BannerModel } = require('../model/banner')

function handleList(req, res) {
    const {
        search,
        page,
        pagesize
    } = req.query
    BannerModel.find().then(result => {
        let arr = result.filter(it => it.imgname.includes(search))
        let obj = {
            code: 1,
            message: '列表请求成功',
            list: arr.slice((page - 1) * pagesize, page * pagesize),
        }
        res.send(obj)
    })
}

function handleList1(req, res) {
    BannerModel.find().then(result => {
        let list = JSON.parse(JSON.stringify(result))
        console.log(list);
        let obj = {
            code: 1,
            message: '列表请求成功111',
            list
        }
        res.send(obj)
    })
}


module.exports = {
    handleList,
    handleList1
}